<?php
include('ps_pagination.php'); 
if(isset($_POST['dcid']))
{
	require("includes/basic.php");
	$cid=$_POST['dcid'];
	$id= split(',',$cid);
	foreach($id as $a => $b)
	{
		$deactivate=mysql_query("update client_master set record_status='N' where client_id=$b");
	}
}
if(isset($_POST['acid']))
{
	require("includes/basic.php");
	$cid=$_POST['acid'];
	$id= split(',',$cid);
	foreach($id as $a => $b)
	{
		$activate=mysql_query("update client_master set record_status='Y' where client_id=$b");
	}
}
if(isset($_POST['s']))
{
	$s=$_POST['s'];
	require("includes/basic.php");
	$sql="select * from client_master where client_created_by='$distusertypeid' and (LOWER(client_name) like LOWER('$s%'))";
}
else
{
$sql= "select * from client_master where client_created_by='$distusertypeid'";
}
$colorIndex = "#242424";
	/*
	 * Create a PS_Pagination object
	 * 
	 * $conn = MySQL connection object
	 * $sql = SQl Query to paginate
	 * 10 = Number of rows per page
	 * 5 = Number of links
	 * "param1=valu1&param2=value2" = You can append your own parameters to paginations links
	 */
	$pager = new PS_Pagination($conn, $sql, 8, 5, "param1=valu1&param2=value2");
	
	/*
	 * Enable debugging if you want o view query errors
	*/
	$pager->setDebug(true);
	
	/*
	 * The paginate() function returns a mysql result set
	 * or false if no rows are returned by the query
	*/
	$rs = $pager->paginate();
	if(!$rs) die(mysql_error());


	$sr=1;
$class="evenrowbg";

?>
<form id='viewclients'> 
	<table width='100%'  class='list'>
	<tr>
		<!-- <th style='white-space: nowrap;'>
			<div style='display:block;'>
				<span class="link linkdisabled">Sr no.</span>
			</div>
		</th> -->
		<th width='5%'  style='white-space: nowrap;'>
			<div style='display:block;'>
				<span class="link linkdisabled">Open</span>
			</div>
		</th>
        <th width='5%' style='white-space: nowrap;'>
			<div style='display:block;'>
				<span class="link linkdisabled">Edit</span>
			</div>
		</th>
		<th width='5%'  style='white-space: nowrap;'>
			<div style='display:block;'>
				<span class="link linkdisabled">Contacts</span>
			</div>
		</th>
		<th width='15%' style='white-space: nowrap;'>
			<div style='display:block;'>
				<span class="link linkdisabled">Client Name</span>
			</div>
		</th>
		<th width='20%' style='white-space: nowrap;'>
			<div style='display:block;'>
				<span class="link linkdisabled">Client Description</span>
			</div>
		</th>
		<th width='10%' style='white-space: nowrap;'>
			<div style='display:block;'>
				<span class="link linkdisabled">Username</span>
			</div>
		</th>
		<!--<th width='10%' style='white-space: nowrap;' align='center'>
			<span class="link linkdisabled">Password</span>
		</th>-->
		<th width='10%' style='white-space: nowrap;'>
			<span class="link linkdisabled">Client Type</span>
		</th>
		<th width='10%' style='white-space: nowrap;'>
			<span class="link linkdisabled">Created on</span>
		</th>
		<th width='5%' style='white-space: nowrap;'>
			<span class="link linkdisabled">Status</span>
		</th>
		<th width='5%' class='select'>
		
<input type='checkbox' class='checkbox' name='allCheck' id='listSelectAll'>
		</th>
	</tr>
	<?php while($clientsr=mysql_fetch_array($rs))
	{
		$clientid=$clientsr['client_id'];
		$clientname=substr($clientsr['client_name'],0,25);
		$clientdesc=substr($clientsr['client_description'], 0, 35)."..";
		$Uname=$clientsr['user_name'];
		$pass=base64_decode($clientsr['password']);
		$ctype=$clientsr['client_type'];
		$status=$clientsr['record_status'];
		$createdon=$clientsr['client_created_on'];
		$cliusertypeid=$clientsr['usertypeid'];
		if($class=="evenrowbg")
		{
			$class="oddrowbg";
		}
		else
		{
			$class="evenrowbg";
		}
		echo "<tr class='$class'>";
		//echo "<td style='text-align:center;'>$sr</td>";
		echo "<td width='5%' style='text-align:center;'><a href='open_cli.php?cli=$clientid'><img src='images/open.png'/></a></td>";
		echo "<td width='5%' style='text-align:center;'><a href='edit-client.php?clid=$clientid'><img src='images/edit.png'/></a></td>";

		echo "<td width='5%' style='text-align:center;'><a href='view-client-contacts.php?clidd=$cliusertypeid'><img src='images/user.png'/></a></td>";

		echo "<td width='15%'>".$clientname."</td><td width='20%'>".$clientdesc."</td><td width='10%'>".$Uname."</td>";
		if($ctype=='P'){echo "<td width='10%'>Prospective</td>";}else{echo "<td width='10%'>Active</td>";}
		echo "<td width='10%'>".$createdon."</td>";
		echo "<td width='5%' style='text-align:center;'>";
		if($status=='Y')
		{
			echo "<img src='images/multi_activate.png' alt='Active' title='Active'>";
		}
		else
		{
			echo "<img src='images/multi_deactivate.png' alt='Disabled' title='Disabled'>";
		}
		echo "</td>";
		echo "<td width='5%' style='text-align:center;'><input type='checkbox' value='$clientid' id='custid' name='chkName'></td>";
		$sr++;
		echo "</tr>";
	}

	?>
</form>
</table>

<?php

	//Display the full navigation in one go
	 echo "<br />\n";?>
	